#pragma once
#include "HashBucket.h"
namespace My_udmap {

	template<class K,class V>
	class unordered_map {
	public:
		struct KofT {
			const K& operator()(const pair<K, V>& kv) {
				return kv.first;
			}
		};
		typedef typename HashBucket::Hash<K, pair<const K,V>, KofT>::iterator iterator;
		typedef typename HashBucket::Hash<K, pair<const K, V>, KofT>::con_iterator con_iterator;

		iterator begin() {
			return mh.begin();
		}
		iterator end() {
			return mh.end();
		}
		con_iterator begin() const{
			return mh.begin();
		}
		con_iterator end() const{
			return mh.end();
		}
		pair<iterator,bool> insert(const pair<K, V>& kv) {
			return mh.Insert(kv);
		}
		V& operator[](const K& key) {
			pair<iterator, bool> ret = mh.Insert(make_pair(key, V()));
		    return ret.first->second;
		}
	private:
		HashBucket::Hash<K,pair<const K,V>,KofT> mh; 
	};
}